package com.qianbei.user.help;

import android.os.Bundle;
import android.view.View;
import android.widget.ListView;

import com.alibaba.fastjson.JSON;
import com.android.volley.Request.Method;
import com.qianbei.R;
import com.qianbei.common.base.BaseActivity;
import com.qianbei.common.net.control.ServerResult;
import com.qianbei.user.feedback.FeedBackActivity;

import java.util.ArrayList;

public class HelpeActivity extends BaseActivity {

	private ListView listView;
	private HelpAdapter helpAdapter;

	private View back_view;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);

		setContentView(R.layout.help_activity_list);
		listView = (ListView) findViewById(R.id.listView);
		helpAdapter = new HelpAdapter(this, new ArrayList<HelpBean>());
		listView.setAdapter(helpAdapter);
		comment_types("");
		setTitle("使用帮助");
		back_view = findViewById(R.id.back_view);
		back_view.setOnClickListener(this);
	}

	@Override
	public void onClick(View v) {
		super.onClick(v);
		switch (v.getId()) {
		case R.id.back_view:
			startActivity(FeedBackActivity.class);
			break;

		default:
			break;
		}
	}

	/**
	 * 隐私声明接口
	 * 
	 * @param tag
	 */
	public void comment_types(String tag) {
		initAlertServer(Method.GET, HELP_URL + "?" + "tag=" + tag + "&");
	}

	@Override
	public void serverFinish(ServerResult sr) {
		if (sr.isContinue) {
			ArrayList<HelpBean> list = (ArrayList) JSON.parseArray(sr.bodyData
					.optJSONArray("help_documentation").toString(),
					HelpBean.class);
			if (list != null) {
				for (HelpBean helpBean : list) {
					helpAdapter.add(helpBean);
					helpAdapter.notifyDataSetChanged();
				}
				back_view.setVisibility(View.VISIBLE);
			} else {
				back_view.setVisibility(View.GONE);
			}

			// loadNativyData(sr.bodyData.optString("statement"));
		}

	}

}
